# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: Exp $

EAPI=2
inherit eutils autotools

INS_DIR="/opt/cern/alice/xrootd"
# XRD_PROG_NAME="xrdbase"
# XRD_PROG_VER="${PV/./-}"
XRD_OPENSSL_VER="openssl-alien-0.9.8q"
XRD_OPENSSL_DIR="/opt/cern/alice/$XRD_OPENSSL_VER"

#XRD_PROG_VER="20100115-1117"
XROOTD_VER="PRO"

DESCRIPTION="ALICE ${PN} for xrootd"
SRC_URI="http://xrootd.slac.stanford.edu/download/v${PV}/${P}.tar.gz"

HOMEPAGE="http://xrootd.slac.stanford.edu/"

SLOT="3.1"
LICENSE="GPL-2"
KEYWORDS="~amd64 ~x86"

IUSE=""

CDEPEND="dev-libs/libxml2
        =dev-libs/$XRD_OPENSSL_VER"

DEPEND="${CDEPEND}
  dev-util/pkgconfig
  >=sci-physics/eselect-alice-1.9.7
  >=sci-physics/eselect-xrootd-2.0.3"

S="${WORKDIR}/${P}"

src_configure() {
  mkdir -p ${WORKDIR}/${P}_build
  cd ${WORKDIR}/${P}_build
  cmake -DOPENSSL_ROOT_DIR="$XRD_OPENSSL_DIR" -DCMAKE_INSTALL_PREFIX="${D}/$INS_DIR/${PV}" ${WORKDIR}/${P} || die "configure failed"
}

src_compile() {
  cd ${WORKDIR}/${P}_build
  emake || die "emake failed"
}


src_install() {
  cd ${WORKDIR}/${P}_build
  emake install || die "emake install failed"
}
